package nongchang.kuaijiecaifu.com.ncapp_android.ui.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import butterknife.BindView;
import butterknife.ButterKnife;
import ezy.lite.util.ContextUtil;
import ezy.lite.util.UI;
import ezy.widget.view.AutofitImageView;
import nongchang.kuaijiecaifu.com.ncapp_android.R;
import nongchang.kuaijiecaifu.com.ncapp_android.common.adapter.ItemAdapter;
import nongchang.kuaijiecaifu.com.ncapp_android.retrofit.good.Good;
import nongchang.kuaijiecaifu.com.ncapp_android.retrofit.good.Raffle;
import nongchang.kuaijiecaifu.com.ncapp_android.retrofit.main.Follow;
import nongchang.kuaijiecaifu.com.ncapp_android.ui.HowToCalActivity;

/**
 * Created by Administrator on 2016/3/12 0012.
 */
public class RaffleAdapter extends ItemAdapter<Raffle, RaffleAdapter.RaffleHolder> {
    private Context context;

    public RaffleAdapter(Context context) {
        super(context);
        this.context = context;
    }

    @Override
    public RaffleHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new RaffleHolder(inflate(R.layout.item_raffle, parent));
    }

    @Override
    public void onBindViewHolder(RaffleHolder holder, int position) {
        Raffle item = getItem(position);
        holder.txtTitle.setText(item.title);
        holder.txtTime.setText(item.time);
        Glide.with(context).load("http://v1.qzone.cc/pic/201407/13/11/05/53c1f77cdbd01600.jpg%21600x600.jpg").into(holder.imgIcon);
        UI.setTvHtml(holder.txtRaffle, R.string.raffle_detail, item.name, item.number, item.num);
        holder.txtCal.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ContextUtil.startActivity(context, HowToCalActivity.class);
            }
        });
    }


    static class RaffleHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
        @BindView(R.id.txt_title)
        TextView txtTitle;
        @BindView(R.id.txt_time)
        TextView txtTime;
        @BindView(R.id.img_icon)
        ImageView imgIcon;
        @BindView(R.id.txt_raffle)
        TextView txtRaffle;
        @BindView(R.id.txt_calculate)
        TextView txtCal;

        public RaffleHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
            itemView.setOnClickListener(this);
        }

        @Override
        public void onClick(View v) {

        }
    }
}
